import localforage from 'localforage';
import { defineStore } from 'pinia';

export const useIndexedDBStore = defineStore('indexedDB', {
  state: () => ({
    filesDB: localforage.createInstance({
      name: 'filesDB',
    }),
    usersDB: localforage.createInstance({
      name: 'usersDB',
    }),
  }),

  actions: {
    setFilesDB(key: string, data: any) {
      this.filesDB.setItem(key, data);
    },
    getFilesDB(key: string) {
      return this.filesDB.getItem(key);
    },
  },
});
